#include "http_service.h"

#include <boost/bind.hpp>
#include <boost/asio.hpp>

#include "base/logging.h"

using namespace boost::asio;

namespace imserver {

boost::asio::io_service g_io_service;
time_t g_alive_since;

void CometServer::StartAccept() {
  CometConnectionPtr new_connection =
    CometConnection::Create(acceptor_.get_io_service());

  acceptor_.async_accept(new_connection->socket(),
      boost::bind(&CometServer::HandleAccept, this, new_connection,
        boost::asio::placeholders::error));
}

void CometServer::HandleAccept(CometConnectionPtr new_connection,
    const boost::system::error_code& error)
{
  if (error) {
    LOG_WARN("connection accept error : " << error);
  } else {
    new_connection->Start();
  }

  StartAccept();
}

}


